package com.lucky.auth_boot.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.lucky.auth_boot.common.Result;
import com.lucky.auth_boot.pojo.dto.PirateDTO;
import com.lucky.auth_boot.pojo.po.PiratePO;
import com.lucky.auth_boot.service.PirateService;
import jakarta.annotation.Resource;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pirate")
public class PirateController {

    @Resource
    private PirateService pirateService;

    @GetMapping("/getPirateUrlList")
    public Result<?> getPirateUrlList() {
        return Result.success(pirateService.queryPirateDoaminList());
    }

    @GetMapping("/getPirateUrById")
    public Result<?> getPirateUrById(@RequestParam("id") Integer id) {
        return Result.success(pirateService.queryPirateDomainById(id));
    }

    @DeleteMapping("/deletePirateUrlById")
    public Result<?> deletePirateUrlById(@RequestParam("id") Integer id) {
        return Result.success(pirateService.deletePirateDomainById(id));
    }

    @DeleteMapping("/deletePirateDomainById")
    public Result<?> deletePirateDomainById(@RequestParam("id") Integer id) {
        return Result.success(pirateService.deletePirateDomainByIds(id));
    }

    @PutMapping("/putPirateUrl")
    public Result<?> putPirateUrl(@RequestBody PiratePO piratePO) {
        return Result.success(pirateService.updatePirateDomain(piratePO));
    }

    @PostMapping("/addPirateUrl")
    public Result<?> addPirateUrl(@RequestBody PiratePO piratePO) {
        return Result.success(pirateService.addPirateDomain(piratePO));
    }

    @GetMapping("/queryPirateUrlListPage")
    public Result<?> queryPirateUrlListPage(Pageable pageable, PirateDTO pirateDTO) {
        return Result.success(pirateService.queryPirateUrlListPage(pageable,pirateDTO));
    }

    @GetMapping("/queryPirateOneById")
    public Result<?> queryPirateOneById(@RequestParam("id") Integer id) {
        return Result.success(pirateService.queryPirateOneById(id));
    }
}
